package com.yzh.openai.trigger.mq.producer;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
@Slf4j
@Component
public class RedisPublisher {
    @Resource
    private RedissonClient redissonClient;
    public static final String CHANNEL = "order_delivery";
    
    public void publishOrder(String orderId) {
        if (!StringUtils.isNotBlank(orderId)) {
            log.error("RedisPublisher: orderId is null");
            return;
        }
        RTopic topic = redissonClient.getTopic(CHANNEL);
        topic.publish(orderId);
    }
}
